package com.ruoyi.pet.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pet.domain.PetSymptom;
import com.ruoyi.pet.service.IPetSymptomService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 医生主诉描述Controller
 * 
 * @author ruoyi
 * @date 2023-09-01
 */
@RestController
@RequestMapping("/pet/symptom")
public class PetSymptomController extends BaseController
{
    @Autowired
    private IPetSymptomService petSymptomService;

    /**
     * 查询医生主诉描述列表
     */
//    @PreAuthorize("@ss.hasPermi('pet:symptom:list')")
    @GetMapping("/list")
    public TableDataInfo list(PetSymptom petSymptom)
    {
        startPage();
        List<PetSymptom> list = petSymptomService.selectPetSymptomList(petSymptom);
        return getDataTable(list);
    }

    /**
     * 导出医生主诉描述列表
     */
    @PreAuthorize("@ss.hasPermi('pet:symptom:export')")
    @Log(title = "医生主诉描述", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PetSymptom petSymptom)
    {
        List<PetSymptom> list = petSymptomService.selectPetSymptomList(petSymptom);
        ExcelUtil<PetSymptom> util = new ExcelUtil<PetSymptom>(PetSymptom.class);
        util.exportExcel(response, list, "医生主诉描述数据");
    }

    /**
     * 获取医生主诉描述详细信息
     */
//    @PreAuthorize("@ss.hasPermi('pet:symptom:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(petSymptomService.selectPetSymptomById(id));
    }

    /**
     * 新增医生主诉描述
     */
    @PreAuthorize("@ss.hasPermi('pet:symptom:add')")
    @Log(title = "医生主诉描述", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PetSymptom petSymptom)
    {
        return toAjax(petSymptomService.insertPetSymptom(petSymptom));
    }

    /**
     * 修改医生主诉描述
     */
    @PreAuthorize("@ss.hasPermi('pet:symptom:edit')")
    @Log(title = "医生主诉描述", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PetSymptom petSymptom)
    {
        return toAjax(petSymptomService.updatePetSymptom(petSymptom));
    }

    /**
     * 删除医生主诉描述
     */
    @PreAuthorize("@ss.hasPermi('pet:symptom:remove')")
    @Log(title = "医生主诉描述", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(petSymptomService.deletePetSymptomByIds(ids));
    }
}
